﻿@{
    ViewBag.Title = "仓库物品添加";
    Layout = "~/Views/Shared/_LayoutIndex.cshtml";
}@using LeSoft.Application.Code;
<script>
    var keyValue = request('keyValue'), organizeid = "";
    var _organizeid = "@OperatorProvider.Provider.Current().CompanyId", _pstructId = "", _allcode = "", WIDTH = "";
    $(function () {
        initControl();
    })

    //初始化控件
    function initControl() {

        $("#WarehouseId").ComboBoxTree({
            url: "../../ResourceManage/RS_Warehouse/GetTreeJson",
            description: "==请选仓库==",
            height: "150px"
        });
        $("#Type").ComboBoxTree({
            url: "../../ResourceManage/RS_Product/GetTypeTreeJson",
            description: "==请选物品分类==",
            height: "180px",
            click: function () {
                var type = $("#Type").attr('data-value');
                $.ajax({
                    url: "../../ResourceManage/RS_Warehouse/ChkType",
                    type: "post",
                    dataType: "text",
                    data: { key: "Product", Type: type },
                    success: function (data) {
                        if (data != "") {
                            dialogMsg(data, 0)
                        }
                    }
                })
            }
        });

        $("#ProductId").ComboBox({
            //  url: "../../SystemManage/DataItemDetail/GetDataItemTreeJson?Encode=EnergyMeterType",
            data: [{ "key": "1", "value": "测试1" }, { "key": "2", "value": "测试2" }, { "key": "3", "value": "测试3" }],
            id: "key",
            text: "value",
            description: "==请选择==",
            height: "150px"

        });
        $("#BudgetItemId").ComboBox({
            //  url: "../../SystemManage/DataItemDetail/GetDataItemTreeJson?Encode=EnergyMeterType",
            data: [{ "key": "1", "value": "测试科目1" }, { "key": "2", "value": "测试科目2" }, { "key": "3", "value": "测试科目3" }],
            id: "key",
            text: "value",
            description: "==请选预算科目==",
            height: "150px"
        });
        //获取表单
        if (!!keyValue) {
            $.SetForm({
                url: "../../ResourceManage/RS_ProductStock/GetWarehouseProductFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    $("#WarehouseProduct").SetWebControls(data);
                }
            });
        }

    }
    //保存表单
    function AcceptClick() {
        if (!$('#WarehouseProduct').Validform()) {
            return false;
        }
        var postData = $("#WarehouseProduct").GetWebControls(keyValue);
        $.SaveForm({
            url: "../../ResourceManage/RS_ProductStock/SaveWarehouseProducForm?keyValue=" + keyValue,
            param: postData,
            loading: "正在保存数据...",
            success: function () {

                $.currentIframe().$("#gridTable").trigger("reloadGrid");
            }
        })
    }

</script>
<div class="ui-layout" id="layout" style="height: 100%; width: 95%;">
    <table class="form" id="WarehouseProduct" style="margin:0px auto; ">
        <tr style="height:10px;"></tr>
        <tr>
            <td class="formTitle">物品名称<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="Name" class="form-control" isvalid="yes" checkexpession="NotNull" type="text" /></td>
            <td class="formTitle">物品编号<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="Code" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
        </tr>
        <tr>
            <td class="formTitle">品牌<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="Brand" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
            <td class="formTitle">产品规格<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="ModelNo" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
        </tr>
        <tr>
            <td class="formTitle">金额<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="Price" type="number" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
            <td class="formTitle">是否有效<font face="宋体">*</font></td>
            <td class="formValue" colspan="3">
                <div class="checkbox">
                    <label>
                        <input id="EnabledMark" type="checkbox" checked="checked" />
                        有效
                    </label>
                </div>
            </td>
        </tr>
        <tr>
            <td class="formTitle">税率<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="Tax" type="number" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
            <td class="formTitle">含税单价<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="TaxUnitPrice" type="number" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
        </tr>
        <tr>
            <td class="formTitle">单价<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="UnitPrice" type="number" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
            <td class="formTitle">平均单价<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="AverageUnitPrice" type="number" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
        </tr>
        <tr>
            <td class="formTitle">库存<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="Num" type="number" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
            <td class="formTitle">最小库存<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="MinVolume" type="number" value="0" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
        </tr>
        <tr>
            <td class="formTitle">总价<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="TotalUnitPrice" type="number" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
            <td class="formTitle">最大库存<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="MaxVolume" type="number" value="999" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
        </tr>

        <tr>
            <td class="formTitle">产品ID<font face="宋体">*</font></td>
            <td class="formValue" colspan="7">
                <div id="ProductId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
        </tr>
        <tr>
            <td class="formTitle">物品类型<font face="宋体">*</font></td>
            <td class="formValue" colspan="7">
                <div id="Type" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <td class="formTitle">选择仓库<font face="宋体">*</font></td>
            <td class="formValue" colspan="7">
                <div id="WarehouseId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <td class="formTitle">所属预算科目<font face="宋体">*</font></td>
            <td class="formValue" colspan="7">
                <div id="BudgetItemId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <td class="formTitle">备注</td>
            <td class="formValue" colspan="7"><textarea id="Description" class="form-control" style="height: 70px;"></textarea></td>
        </tr>
    </table>
</div>
